wpt->usecount = isroute ? 1 : 0;
wpt->checked = isroute ? 0 : 1;
wpt->reserved = 0;
- pack_time(WP->GetCreationTime(), &(wpt->date), &(wpt->time));
+ pack_time(WP->GetCreationTime().toTime_t(), &(wpt->date), &(wpt->time));
wpthdr->idx[hdr_idx] = wpt_idx;
wpthdr->used[wpt_idx] = WPT_USED;
}
- rec->creation_time = rec->modification_time = wpt->GetCreationTime();
+ rec->creation_time = rec->modification_time = wpt->GetCreationTime().toTime_t();
rec->lat = EncodeOrd(wpt->latitude);
rec->lon = EncodeOrd(-wpt->longitude);
rec->serial = serial++;
}
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYTYPE_WPT; /* CWpt */
file_out->creator = MYCREATOR; /* cGPS */
file_out->version = 1;
static QString
ce_gen_current_time(void)
{
- return ce_gen_creation_time(current_time());
+ return ce_gen_creation_time(current_time().toTime_t());
}
/* Generate a UUID (has same format as Microsoft registry GUIDs */
id = xml_buffer;
}
write_xml_entity_begin2(ofd, "\t", "Mark",
- "created", ce_gen_creation_time(wp->GetCreationTime()),
+ "created", ce_gen_creation_time(wp->GetCreationTime().toTime_t()),
"id", id);
ce_waypt_pr(wp);
write_xml_entity_end(ofd, "\t", "Mark");
the standalone waypoints.
*/
time_t now = 0;
- now = current_time();
+ now = current_time().toTime_t();
write_xml_header(ofd);
write_xml_entity_begin1(ofd, "", "NavObjectCollection", "created",
// TOOD: This should probably attempt a gmtime and then fall back to the 1-1-1970
// case or bypass the time_t completely and build string representations directly.
if (wpt->creation_time.isValid()) {
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
struct tm tm = *gmtime(&tt);
strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm);
strncpy(file_out->name, out_fname, PDB_DBNAMELEN);
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = wayp_TYPE;
file_out->creator = GXPU_CREATOR;
file_out->version = 4;
return strftime(buff, bufsize, format, stmp);
}
+static
+int
+writetime(char* buff, size_t bufsize, const char* format, const gpsbabel::DateTime& t, bool gmt)
+{
+ return writetime(buff, bufsize, format, t.toTime_t(), gmt);
+}
+
static
int
writehms(char* buff, size_t bufsize, const char* format, time_t t, int gmt)
(stmp->tm_hour>=12?"PM":"AM"));
}
+static
+int
+writehms(char* buff, size_t bufsize, const char* format, const gpsbabel::DateTime& t, int gmt)
+{
+ return writehms(buff, bufsize, format, t.toTime_t(), gmt);
+}
+
static
long
time_to_yyyymmdd(QDateTime t)
/* TIME CONVERSIONS**************************************************/
case XT_EXCEL_TIME:
/* creation time as an excel (double) time */
- writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime()));
+ writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()));
break;
case XT_TIMET_TIME:
/* time as a time_t variable */ {
}
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- time_t logtime = xml_parse_time(logpart->cdata);
+ time_t logtime = xml_parse_time(logpart->cdata).toTime_t();
const struct tm* logtm = gmtime(&logtime);
gbfprintf(fd, "%d-%02d-%02d ", logtm->tm_year + 1900, logtm->tm_mon + 1, logtm->tm_mday);
}
waypoint_i++;
le_write32(p->total, waypoint_n);
le_write32(p->index, waypoint_i);
- encode_time(wp->GetCreationTime(), &p->year);
+ encode_time(wp->GetCreationTime().toTime_t(), &p->year);
le_write32(p->latitude, delbin_deg2rad(wp->latitude));
le_write32(p->longitude, delbin_deg2rad(wp->longitude));
if (wp->altitude > unknown_alt) {
le_write32(p->index, i + 1);
}
assert(p);
- encode_time(wp->GetCreationTime(), &p->point[j].year);
+ encode_time(wp->GetCreationTime().toTime_t(), &p->point[j].year);
le_write32(p->point[j].latitude, delbin_deg2rad(wp->latitude));
le_write32(p->point[j].longitude, delbin_deg2rad(wp->longitude));
f = UNKNOWN_ELEV;
if (track->rte_name) {
strncpy(p->name, track->rte_name, sizeof(p->name) - 1);
} else {
- sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
+ sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t());
}
le_write32(p->total_points, waypoint_n);
- encode_time(current_time(), &p->year);
+ encode_time(current_time().toTime_t(), &p->year);
le_write16(p->color, track_color_index(track->line_color.bbggrr));
le_write16(p->comment_size, comment_size);
if (comment_size) {
if (route->rte_name) {
strncpy(p->name, route->rte_name, sizeof(p->name) - 1);
} else {
- sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
+ sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t());
}
p->type = 0;
le_write32(p->total_route_point, route_point_n);
le_write_double(&gp.alt, alt_feet);
le_write_double(&gp.speed, speed);
le_write_double(&gp.heading, heading);
- le_write32(&gp.tm, wpt->GetCreationTime());
+ le_write32(&gp.tm, wpt->GetCreationTime().toTime_t());
gbfwrite(&gp, sizeof(gp), 1, gplfile_out);
}
if (exif_wpt_ref == NULL) {
exif_wpt_ref = wpt;
- } else if (abs(exif_time_ref - wpt->creation_time) < abs(exif_time_ref - exif_wpt_ref->creation_time)) {
+ } else if (abs(exif_time_ref - wpt->creation_time.toTime_t()) < abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t())) {
exif_wpt_ref = wpt;
}
}
if (exif_wpt_ref == NULL) {
warning(MYNAME ": No point with a valid timestamp found.\n");
- } else if (abs(exif_time_ref - exif_wpt_ref->creation_time) > frame) {
+ } else if (abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()) > frame) {
warning(MYNAME ": No matching point found for image date %s!\n", str);
if (exif_wpt_ref != NULL) {
- char* str = exif_time_str(exif_wpt_ref->creation_time);
+ char* str = exif_time_str(exif_wpt_ref->creation_time.toTime_t());
warning(MYNAME ": Best is from %s, %d second(s) away.\n",
- str, abs(exif_time_ref - exif_wpt_ref->creation_time));
+ str, abs(exif_time_ref - exif_wpt_ref->creation_time.toTime_t()));
xfree(str);
}
exif_wpt_ref = NULL;
exif_put_double(GPS_IFD, GPS_IFD_TAG_ALT, 0, wpt->altitude);
}
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
struct tm tm;
char buf[32];
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *gmtime(&tt);
tm.tm_year += 1900;
* an affected unit.
*/
if (resettime) {
- GPS_Command_Send_Time(fname, current_time());
+ GPS_Command_Send_Time(fname, current_time().toTime_t());
return;
}
int i;
for (i=(nlaps-1); i >= 0; i--) {
GPS_PLap lap = laps[i];
- time_t delta = lap->start_time - wpt->GetCreationTime();
+ time_t delta = lap->start_time - wpt->GetCreationTime().toTime_t();
if ((delta >= -1) && (delta <= 1)) {
result = 1;
break;
waypoint* prev = cur_info->prev_wpt;
if (prev != NULL) {
- cur_info->time += (wpt->GetCreationTime() - prev->GetCreationTime());
+ cur_info->time += (wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t());
cur_info->length += waypt_distance_ex(prev, wpt);
} else {
cur_info->first_wpt = (waypoint*)wpt;
- cur_info->start = wpt->GetCreationTime();
+ cur_info->start = wpt->GetCreationTime().toTime_t();
}
cur_info->prev_wpt = (waypoint*)wpt;
cur_info->count++;
print_string("%s\t", GMSD_GET(state, ""));
country = gt_get_icao_country(GMSD_GET(cc, ""));
print_string("%s\t", (country != NULL) ? country : "");
- print_date_and_time(wpt->GetCreationTime(), 0);
+ print_date_and_time(wpt->GetCreationTime().toTime_t(), 0);
if (wpt->HasUrlLink()) {
UrlLink l = wpt->GetUrlLink();
print_string("%s\t", l.url_);
gbfprintf(fout, "Trackpoint\t");
print_position(wpt);
- print_date_and_time(wpt->GetCreationTime(), 0);
+ print_date_and_time(wpt->GetCreationTime().toTime_t(), 0);
if IS_VALID_ALT(wpt->altitude) {
print_distance(wpt->altitude, 1, 0, 0);
}
if (prev != NULL) {
float temp;
gbfprintf(fout, "\t");
- delta = wpt->GetCreationTime() - prev->GetCreationTime();
+ delta = wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t();
temp = WAYPT_GET(wpt, temperature, -999);
if (temp != -999) {
print_temperature(temp);
strncpy(file_out->name, "GeocachingDB", PDB_DBNAMELEN);
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYTYPE; /* CWpt */
file_out->creator = MYCREATOR; /* cGPS */
file_out->version = 1;
FWRITE_i16(GMSD_GET(category, gdb_category));
FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0);
- FWRITE_TIME(wpt->GetCreationTime());
+ FWRITE_TIME(wpt->GetCreationTime().toTime_t());
/* VERSION DEPENDENT CODE */
if (gdb_ver >= GDB_VER_3) {
FWRITE_LATLON(wpt->latitude);
FWRITE_LATLON(wpt->longitude);
FWRITE_DBL(wpt->altitude, unknown_alt);
- FWRITE_TIME(wpt->GetCreationTime());
+ FWRITE_TIME(wpt->GetCreationTime().toTime_t());
d = WAYPT_GET(wpt, depth, unknown_alt);
FWRITE_DBL(d, unknown_alt);
d = WAYPT_GET(wpt, temperature, -99999);
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + (49*365 + 17*366) * (60*60*24);
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + (49*365 + 17*366) * (60*60*24);
file_out->type = MYTYPE_ASC;
file_out->creator = MYCREATOR;
file_out->version = 0;
latsec = 60.0 * (latmin - floor(latmin));
lonsec = 60.0 * (lonmin - floor(lonmin));
- if (wpt->creation_time > 0) {
+ if (wpt->creation_time.isValid()) {
time_t t = wpt->GetCreationTime().toTime_t();
tm = *gmtime(&t);
tm.tm_mon += 1;
wpt->latitude, wpt->longitude);
speed = waypt_speed(prev, wpt);
}
- if (wpt->creation_time > 0) {
+ if (wpt->creation_time.isValid()) {
secs = (double)tm.tm_sec + wpt->GetCreationTime().time().msec() / 1000.0;
}
{
gnav_trl_t rec;
- le_write32(&rec.time, wpt->GetCreationTime());
+ le_write32(&rec.time, wpt->GetCreationTime().toTime_t());
le_write_float(&rec.lat, wpt->latitude);
le_write_float(&rec.lon, wpt->longitude);
if (wpt->altitude != unknown_alt) {
//calculate the speed to reach this waypoint from the last. This way I try to sort out invalid waypoints
speed=0;
if (lastwpt !=NULL) {
- speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->GetCreationTime());
+ speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) /
+ abs(wpt->creation_time.toTime_t() - lastwpt->GetCreationTime().toTime_t());
//printf("speed line %d %lf \n",line,speed);
}
/* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */
}
}
//MSVC handles time_t as int64, gcc and mac only int32, so convert it:
- timestamp=(unsigned long)wpt->GetCreationTime();
+ timestamp=(unsigned long)wpt->GetCreationTime().toTime_t();
gbfprintf(fout, "%lu, %s, %lf, %lf, %5.1lf, %8.5lf, %d, %lf, %d\n",timestamp,tbuffer, wpt->longitude, wpt->latitude,wpt->altitude,
wpt->speed,fix,wpt->hdop,wpt->sat);
}
*/
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYWPT;
file_out->creator = MYCREATOR;
}
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYTYPE_POINTS;
file_out->creator = MYCREATOR;
file_out->version = 0;
* Make sure that all waypoints in single read have same
* timestamp.
*/
- time_t now = current_time();
+ time_t now = current_time().toTime_t();
icon[0] = 0;
while ((ibuf = gbfgetstr(file_in))) {
waypt_alloc_gc_data(wpt_tmp)->placer = cdatastrp;
break;
case tt_cache_log_date:
- gc_log_date = xml_parse_time(cdatastrp);
+ gc_log_date = xml_parse_time(cdatastrp).toTime_t();
break;
/*
* "Found it" logs follow the date according to the schema,
*/
case tt_cache_log_type:
if ((0 == strcmp(cdatastrp, "Found it")) &&
- (0 == wpt_tmp->gc_data->last_found)) {
+ (0 == wpt_tmp->gc_data->last_found.toTime_t())) {
waypt_alloc_gc_data(wpt_tmp)->last_found = gc_log_date;
}
gc_log_date = 0;
}
fread_discard(file_in, 1);
wpt->creation_time = fread_long(file_in);
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
wpt->creation_time += EPOCH89DIFF;
}
fread_discard(file_in, 2);
wpt->longitude = fread_double(file_in);
convert_datum(&wpt->latitude, &wpt->longitude);
wpt->SetCreationTime(fread_long(file_in));
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
wpt->creation_time += EPOCH89DIFF;
}
start_new = fread_byte(file_in);
fwrite_string(file_out, wpt->description);
fwrite_integer(file_out, icon_from_descr(wpt->icon_descr));
fwrite_byte(file_out, 3);
- if (wpt->creation_time) {
- fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
+ if (wpt->creation_time.isValid()) {
+ fwrite_long(file_out, wpt->GetCreationTime().toTime_t()-EPOCH89DIFF);
} else {
fwrite_long(file_out, 0);
}
{
fwrite_double(file_out, wpt->latitude);
fwrite_double(file_out, wpt->longitude);
- fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
+ fwrite_long(file_out, wpt->GetCreationTime().toTime_t()-EPOCH89DIFF);
fwrite_byte(file_out, start_new);
if (wpt->altitude == unknown_alt) {
fwrite_single(file_out, unknown_alt_gtm);
static void
gtc_study_lap(const waypoint* wpt)
{
- if (wpt->creation_time && (gtc_least_time == 0)) {
+ if (wpt->creation_time.isValid() && (!gtc_least_time.isValid())) {
gtc_least_time = wpt->GetCreationTime();
gtc_start_lat = wpt->latitude;
gtc_start_long = wpt->longitude;
}
- if (wpt->creation_time && (gtc_least_time > wpt->GetCreationTime())) {
+ if (wpt->creation_time.isValid() && (gtc_least_time > wpt->GetCreationTime())) {
gtc_least_time = wpt->GetCreationTime();
gtc_start_lat = wpt->latitude;
gtc_start_long = wpt->longitude;
gtc_write_xml(1, "<Trackpoint>\n");
}
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
QString time_string = wpt->CreationTimeXML();
if (!time_string.isEmpty()) {
gtc_write_xml(0, "<Time>%s</Time>\n",
gtc_fake_hdr(void)
{
long secs = 0;
- if (gtc_least_time && gtc_most_time) {
- secs = gtc_most_time - gtc_least_time;
+ if (gtc_least_time.isValid() && gtc_most_time.isValid()) {
+ secs = gtc_most_time.toTime_t() - gtc_least_time.toTime_t();
}
/* write these in either case, course or activity format */
gtc_lap_start(NULL);
gtc_new_study_lap(rte);
route_disp(rte, gtc_study_lap);
- if (gtc_least_time) {
+ if (gtc_least_time.isValid()) {
gtc_write_xml(0, "<Id>%s</Id>\n",
- gtc_least_time.toPrettyString().toUtf8().data());
+ CSTR(gtc_least_time.toPrettyString()));
gtc_write_xml(1, "<Lap StartTime=\"%s\">\n",
- gtc_least_time.toPrettyString().toUtf8().data());
+ CSTR(gtc_least_time.toPrettyString()));
} else {
gtc_write_xml(1, "<Lap>\n");
}
hiketech_trkpt_pr(const waypoint* waypointp)
{
gbfprintf(ofd, " <pnt>\n");
- if (waypointp->creation_time) {
- hiketech_print_utc(waypointp->GetCreationTime(), " ", "utc");
+ if (waypointp->creation_time.isValid()) {
+ hiketech_print_utc(waypointp->GetCreationTime().toTime_t(), " ", "utc");
}
gbfprintf(ofd, " <lat>%f</lat>\n", waypointp->latitude);
gbfprintf(ofd, " <long>%f</long>\n", waypointp->longitude);
}
/*set the time */
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
/* tm = gmtime(&wpt->creation_time);*/ /* I get the wrong result with gmtime ??? */
QDate date(wpt->GetCreationTime().date());
QTime time(wpt->GetCreationTime().time());
{
char tbuf[1024];
char* cout;
- time_t tm = wpt->GetCreationTime();
+ time_t tm = wpt->GetCreationTime().toTime_t();
int32_t utmz;
double utme, utmn;
char utmzc;
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata);
+ logtime = xml_parse_time(logpart->cdata).toTime_t();
logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
hum.depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0);
be_write16(&hum.depth, hum.depth);
- be_write32(&hum.time, wpt->GetCreationTime());
+ be_write32(&hum.time, wpt->GetCreationTime().toTime_t());
east = wpt->longitude / 180.0 * EAST_SCALE;
be_write32(&hum.east, si_round((east)));
north = si_round(inverse_gudermannian_i1924(lat));
if (wpt->creation_time.isValid()) {
- last_time = wpt->GetCreationTime();
+ last_time = wpt->GetCreationTime().toTime_t();
}
if (i == 0) {
track = pres_track;
}
// Date in header record is that of the first fix record
- date = !track ? current_time() :
- ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime();
+ date = !track ? current_time().toTime_t() :
+ ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime().toTime_t();
if (NULL == (tm = gmtime(&date))) {
fatal(MYNAME ": Bad track timestamp\n");
fatal(MYNAME ": Too much waypoints (more than 99) in task route.\n");
}
// Gather data to write to the task identification (first) record
- rte_time = wpt->GetCreationTime() ? wpt->GetCreationTime() : current_time();
+ rte_time = wpt->GetCreationTime().isValid() ? wpt->GetCreationTime().toTime_t() : current_time().toTime_t();
if (NULL == (tm = gmtime(&rte_time))) {
fatal(MYNAME ": Bad task route timestamp\n");
}
{
struct tm* tm;
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = gmtime(&tt);
if (NULL == tm) {
return 0;
}
} while (alt_diff > -10.0);
- pres_time = ((waypoint*) elem->next)->GetCreationTime();
+ pres_time = ((waypoint*) elem->next)->GetCreationTime().toTime_t();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": pressure landing time %s", ctime(&pres_time));
}
return 0;
}
// Get a crude indication of groundspeed from the change in lat/lon
- time_diff = wpt->GetCreationTime() - ((waypoint*) elem)->GetCreationTime();
+ time_diff = wpt->GetCreationTime().toTime_t() - ((waypoint*) elem)->GetCreationTime().toTime_t();
speed = !time_diff ? 0 :
(fabs(wpt->latitude - ((waypoint*) elem)->latitude) +
fabs(wpt->longitude - ((waypoint*) elem)->longitude)) / time_diff;
printf(MYNAME ": speed=%f\n", speed);
}
} while (speed < 0.00003);
- gnss_time = ((waypoint*) elem->next)->GetCreationTime();
+ gnss_time = ((waypoint*) elem->next)->GetCreationTime().toTime_t();
if (global_opts.debug_level >= 1) {
printf(MYNAME ": gnss landing time %s", ctime(&gnss_time));
}
curr_elem = prev_elem = QUEUE_FIRST(&track->waypoint_list);
}
// Find the track points either side of the requested time
- while (((waypoint*) curr_elem)->GetCreationTime() < time) {
+ while (((waypoint*) curr_elem)->GetCreationTime().toTime_t() < time) {
if (QUEUE_LAST(&track->waypoint_list) == curr_elem) {
// Requested time later than all track points, we can't interpolate
return unknown_alt;
curr_wpt = (waypoint*) curr_elem;
if (QUEUE_FIRST(&track->waypoint_list) == curr_elem) {
- if (curr_wpt->GetCreationTime() == time) {
+ if (curr_wpt->GetCreationTime().toTime_t() == time) {
// First point's creation time is an exact match so use it's altitude
return curr_wpt->altitude;
} else {
}
}
// Interpolate
- if (0 == (time_diff = curr_wpt->GetCreationTime() - prev_wpt->GetCreationTime())) {
+ if (0 == (time_diff = curr_wpt->GetCreationTime().toTime_t() - prev_wpt->GetCreationTime().toTime_t())) {
// Avoid divide by zero
return curr_wpt->altitude;
}
alt_diff = curr_wpt->altitude - prev_wpt->altitude;
- return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime());
+ return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime().toTime_t());
}
/*
// Iterate through waypoints in both tracks simultaneously
QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) {
wpt = (waypoint*) elem;
- pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime() + time_adj);
+ pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime().toTime_t() + time_adj);
wr_fix_record(wpt, (int) pres_alt, (int) wpt->altitude);
}
} else {
}
track_num = 0;
- now = current_time();
+ now = current_time().toTime_t();
tm = *localtime(&now);
gbfprintf(fout, "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n");
// then we shall make our own, where each point is one
// second apart.
if (wpt->creation_time.isValid()) {
- le_write32(&point.unix_time, wpt->GetCreationTime());
+ le_write32(&point.unix_time, wpt->GetCreationTime().toTime_t());
} else {
le_write32(&point.unix_time, invented_time++);
}
first = 0;
} else {
if (opt_interval &&
- wpt->creation_time - time1 > interval) {
+ wpt->creation_time.toTime_t() - time1 > interval) {
for (timen = time1+interval;
- timen < wpt->creation_time;
+ timen < wpt->creation_time.toTime_t();
timen += interval) {
waypoint* wpt_new = waypt_dupe(wpt);
wpt_new->creation_time = timen;
linepart(lat1, lon1,
wpt->latitude, wpt->longitude,
(double)(timen-time1)/
- (double)(wpt->creation_time-time1),
+ (double)(wpt->creation_time.toTime_t() - time1),
&wpt_new->latitude,
&wpt_new->longitude);
if (opt_route) {
distn += dist) {
waypoint* wpt_new = waypt_dupe(wpt);
wpt_new->creation_time = distn/curdist*
- (wpt->creation_time - time1) + time1;
+ (wpt->creation_time.toTime_t() - time1) + time1;
if (wpt_new->shortname) {
xfree(wpt_new->shortname);
}
lat1 = wpt->latitude;
lon1 = wpt->longitude;
- time1 = wpt->creation_time;
+ time1 = wpt->creation_time.toTime_t();
}
}
route_flush(backuproute);
{
le_write32(d->longitude, deg_to_deg_min(wp->longitude));
le_write32(d->latitude, deg_to_deg_min(wp->latitude));
- le_write32(d->creation_time, encode_itracku_time(wp->creation_time));
+ le_write32(d->creation_time, encode_itracku_time(wp->creation_time.toTime_t()));
d->speed = MPS_TO_KNOTS(wp->speed);
le_write16(d->altitude, wp->altitude);
d->flag = 0xff;
struct tm tm;
if (wpt->creation_time.isValid()) {
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *gmtime(&tt);
tm.tm_year += 1900;
writer->writeStartElement("Document");
- now = current_time();
+ now = current_time().toTime_t();
strftime(import_time, sizeof(import_time), "%c", localtime(&now));
if (realtime_positioning) {
writer->writeTextElement("name", "GPS position");
track_add_head(posn_trk_head);
}
- if (last_valid_fix == 0) {
+ if (!last_valid_fix.isValid()) {
last_valid_fix = current_time();
}
last_valid_fix = wpt->GetCreationTime();
}
- wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime() - last_valid_fix);
+ wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime().toTime_t() - last_valid_fix.toTime_t());
/* In order to avoid clutter while we're sitting still, don't add
if (global_opts.debug_level >= 2) {
printf(MYNAME " parse_waypt: creation time %d\n",
- (int)wpt_tmp->creation_time);
+ (int)wpt_tmp->creation_time.toTime_t());
printf(MYNAME " parse_waypt: base_time %d\n", (int)base_time_secs);
printf(MYNAME " parse_waypt: waypt time %d\n", (int)waypt_time);
}
gbfputint32(text_len, file_out);
}
- if (wpt->creation_time > base_time_secs) {
- Time = wpt->creation_time - base_time_secs;
+ if (wpt->creation_time.toTime_t() > base_time_secs) {
+ Time = wpt->creation_time.toTime_t() - base_time_secs;
} else {
Time = 0;
}
if (global_opts.debug_level >= 2) {
time_t wpt_time = Time;
printf(MYNAME " waypt_disp: base_time : %d\n", (int)base_time_secs);
- printf(MYNAME " waypt_disp: creation time : %d\n", (int)wpt->creation_time);
+ printf(MYNAME " waypt_disp: creation time : %d\n", (int)wpt->creation_time.toTime_t());
printf(MYNAME " waypt_disp: waypt time : %d\n", (int)wpt_time);
printf(MYNAME " waypt_disp: waypt time (local): %s\n", ctime(&wpt_time));
}
gbfputflt(WAYPT_GET(wpt, proximity, 0.0), file_out);
/* Creation date/time */
- gbfputint32(lowranceusr4_jd_from_timestamp(wpt->GetCreationTime()), file_out);
- gbfputint32(wpt->GetCreationTime(), file_out);
+ gbfputint32(lowranceusr4_jd_from_timestamp(wpt->GetCreationTime().toTime_t()), file_out);
+ gbfputint32(wpt->GetCreationTime().toTime_t(), file_out);
/* Unused byte */
gbfputc(0, file_out);
gbfputc(0, file_out);
/* Timestamp */
- gbfputint32(wpt->GetCreationTime(), file_out);
+ gbfputint32(wpt->GetCreationTime().toTime_t(), file_out);
/* Long/Lat */
gbfputdbl(wpt->longitude * DEGREESTORADIANS, file_out);
time_t tm_t;
struct tm* tm;
tm = NULL;
- if (wpt->creation_time) {
- const time_t tt = wpt->creation_time;
+ if (wpt->creation_time.isValid()) {
+ const time_t tt = wpt->creation_time.toTime_t();
tm = gmtime(&tt);
}
if (!tm) {
- tm_t = current_time();
+ tm_t = current_time().toTime_t();
tm = gmtime(&tm_t);
}
strncpy(file_out->name, "Companion Waypoints", PDB_DBNAMELEN);
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYTYPE; /* CWpt */
file_out->creator = MYCREATOR; /* cGPS */
file_out->version = 1;
mag_handon();
}
- now = current_time();
+ now = current_time().toTime_t();
/*
* The 315 can take up to 4.25 seconds to respond to initialization
* commands. Time out on the side of caution.
while (!got_version) {
mag_readmsg(trkdata);
- if (current_time() > later) {
+ if (current_time().toTime_t() > later) {
fatal(MYNAME ": No acknowledgment from GPS on %s\n",
portname);
}
ilat = waypointp->latitude;
ilon = waypointp->longitude;
tm = NULL;
- if (waypointp->creation_time) {
- const time_t ct = waypointp->GetCreationTime();
+ if (waypointp->creation_time.isValid()) {
+ const time_t ct = waypointp->GetCreationTime().toTime_t();
tm = gmtime(&ct);
if (tm) {
hms = tm->tm_hour * 10000 + tm->tm_min * 100 +
global_opts.inifile = NULL;
gpsbabel_now = time(NULL); /* gpsbabel startup-time */
- gpsbabel_time = current_time(); /* same like gpsbabel_now, but freezed to zero during testo */
+ gpsbabel_time = current_time().toTime_t(); /* same like gpsbabel_now, but freezed to zero during testo */
#ifdef DEBUG_MEM
debug_mem_open();
}
if (prev) { /* other track or bad timestamp */
- if (wpt->creation_time && (prev->creation_time > wpt->creation_time)) {
+ if (wpt->creation_time.isValid() && (prev->creation_time.toTime_t() > wpt->creation_time.toTime_t())) {
trk = NULL;
} else if (waypt_distance(prev, wpt) > 9999.9) {
trk = NULL;
}
static gpsbabel::DateTime
-read_time_t(void)
+read_datetime(void)
{
int hour = gbfgetint16(fin);
int min = gbfgetint16(fin);
is_fatal((track == NULL), MYNAME ": memory non-enough");
track_add_head(track);
- time_t start_time = read_time_t();
- (void) start_time; // currently not used.
- time_t end_time = read_time_t();
- (void) end_time; // currently not used.
+ (void) read_datetime(); // start_time currently unused
+ (void) read_datetime(); // end_time currently unused
char name[200] = {0};
gbfread((void*)name, 1, 200, fin);
*
* This is rumoured (but yet unconfirmed) to be fixed in f/w 5.12.
*/
- t = wpt->GetCreationTime();
+ t = wpt->GetCreationTime().toTime_t();
if (t < last_time) {
t = last_time;
}
mpsmergeout = 0;
} else {
gbfclose(mps_file_out);
- srand((unsigned) current_time());
+ srand((unsigned) current_time().toTime_t());
for (;;) {
/* create a temporary name based on a random char and the existing name */
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
testwpt = (waypoint*)elem;
if (rte_datapoints == 0) {
- uniqueValue = testwpt->GetCreationTime();
+ uniqueValue = testwpt->GetCreationTime().toTime_t();
}
if (testwpt->latitude > maxlat) {
maxlat = testwpt->latitude;
}
if (uniqueValue == 0) {
- uniqueValue = current_time();
+ uniqueValue = current_time().toTime_t();
}
/* route name */
QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
if (trk_datapoints == 0) {
testwpt = (waypoint*)elem;
- uniqueValue = testwpt->GetCreationTime();
+ uniqueValue = testwpt->GetCreationTime().toTime_t();
}
trk_datapoints++;
}
if (uniqueValue == 0) {
- uniqueValue = current_time();
+ uniqueValue = current_time().toTime_t();
}
/* track name */
mps_trackdatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt)
{
int lat, lon;
- time_t t = wpt->GetCreationTime();
+ time_t t = wpt->GetCreationTime().toTime_t();
char zbuf[10];
double mps_altitude = wpt->altitude;
dt = (prev / SECONDS_PER_DAY) * SECONDS_PER_DAY;
wpt->creation_time += dt;
- if (wpt->creation_time > prev) {
+ if (wpt->creation_time.toTime_t() > prev) {
wpt->creation_time+=SECONDS_PER_DAY;
}
}
- prev = wpt->GetCreationTime();
+ prev = wpt->GetCreationTime().toTime_t();
}
}
}
if (sleepus >= 0) {
gb_sleep(sleepus);
} else {
- long wait_time = wpt->GetCreationTime() - last_time;
+ long wait_time = wpt->GetCreationTime().toTime_t() - last_time;
if (wait_time > 0) {
gb_sleep(wait_time * 1000000);
}
}
}
- last_time = wpt->GetCreationTime();
+ last_time = wpt->GetCreationTime().toTime_t();
}
lat = degrees2ddmm(wpt->latitude);
lon = degrees2ddmm(wpt->longitude);
- time_t ct = wpt->GetCreationTime();
+ time_t ct = wpt->GetCreationTime().toTime_t();
tm = gmtime(&ct);
if (tm) {
hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
((waypoint*)(wpt))->extra_data = id;
gbfprintf(fout, " <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
- if (wpt->creation_time) {
+ if (wpt->creation_time.isValid()) {
QString time_string = wpt->CreationTimeXML();
gbfprintf(fout, " timestamp='%s'", qPrintable(time_string));
}
void
ozi_get_time_str(const waypoint *waypointp, char *buff, gbsize_t buffsz)
{
- if (waypointp->creation_time) {
+ if (waypointp->creation_time.isValid()) {
double time = (waypt_time(waypointp) / SECONDS_PER_DAY) + DAYS_SINCE_1990;
snprintf(buff, buffsz, "%.7f", time);
} else {
{
int latint, lonint;
char tbuf[1024];
- time_t tm = wpt->GetCreationTime();
+ time_t tm = wpt->GetCreationTime().toTime_t();
int32 utmz;
double utme, utmn;
char utmzc;
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata);
+ logtime = xml_parse_time(logpart->cdata).toTime_t();
logtm = localtime(&logtime);
if (logtm) {
docprintf(15,
}
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = DOC_TYPE;
file_out->creator = DOC_CREATOR;
file_out->version = 1;
struct tm now;
- tnow = current_time();
+ tnow = current_time().toTime_t();
now = *localtime(&tnow);
now.tm_year += 1900;
now.tm_mon++;
}
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->creator = PPDB_MAGIC;
file_out->version = 3;
double lon,lat;
int icon_token = 0;
char tbuf[1024];
- time_t tm = wpt->GetCreationTime();
+ time_t tm = wpt->GetCreationTime().toTime_t();
lon = degrees2ddmm(wpt->longitude);
lat = degrees2ddmm(wpt->latitude);
if (tm == 0) {
- tm = current_time();
+ tm = current_time().toTime_t();
}
strftime(tbuf, sizeof(tbuf), "%d-%b-%y %I:%M:%S", localtime(&tm));
strupper(tbuf);
lon = degrees2ddmm(wpt->longitude);
lat = degrees2ddmm(wpt->latitude);
- const time_t ct = wpt->GetCreationTime();
+ const time_t ct = wpt->GetCreationTime().toTime_t();
tm = gmtime(&ct);
strftime(tbuf, sizeof(tbuf), "%d-%b-%y %H:%M:%S", tm); /* currently ...%T does nothing under Windows */
memset(&bc, 0, sizeof(bc));
const time_t tt = wpt->GetCreationTime().toTime_t();
tm = localtime(&tt);
- if (wpt->creation_time) {
- const time_t tt = wpt->GetCreationTime();
+ if (wpt->creation_time.isValid()) {
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = gmtime(&tt);
}
QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
testwpt = (waypoint *)elem;
if (rte_datapoints == 0) {
- uniqueValue = testwpt->GetCreationTime();
+ uniqueValue = testwpt->GetCreationTime().toTime_t();
}
rte_datapoints++;
}
if (uniqueValue == 0) {
- uniqueValue = current_time();
+ uniqueValue = current_time().toTime_t();
}
/* route name */
QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
if (trk_datapoints == 0) {
testwpt = (waypoint *)elem;
- uniqueValue = testwpt->GetCreationTime();
+ uniqueValue = testwpt->GetCreationTime().toTime_t();
}
trk_datapoints++;
}
if (uniqueValue == 0) {
- uniqueValue = current_time();
+ uniqueValue = current_time().toTime_t();
}
/* track name */
static void
psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt)
{
- time_t t = wpt->GetCreationTime();
+ time_t t = wpt->GetCreationTime().toTime_t();
struct tm *tmTime = gmtime(&t);
gbfprintf(psit_file, "%11.6f,%11.6f,",
}
file_out->name[PDB_DBNAMELEN-1] = 0;
file_out->attr = PDB_FLAG_BACKUP;
- file_out->ctime = file_out->mtime = current_time() + 2082844800U;
+ file_out->ctime = file_out->mtime = current_time().toTime_t() + 2082844800U;
file_out->type = MYTYPE; /* CWpt */
file_out->creator = MYCREATOR; /* cGPS */
file_out->version = 1;
}
}
notes = csv_stringclean(notes, LINE_FEED);
- time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->GetCreationTime()) : TIMET_TO_EXCEL(gpsbabel_time);
+ time = wpt->creation_time.isValid() ? TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()) : TIMET_TO_EXCEL(gpsbabel_time);
name = (char *)wpt->extra_data;
gbfprintf(fout, "[Wp%d]" LINE_FEED
tdata->max_cad = (int) thisw->cadence;
}
- if (thisw->GetCreationTime() && (thisw->GetCreationTime() < tdata->start)) {
- tdata->start = thisw->GetCreationTime();
+ if (thisw->GetCreationTime().isValid() && (thisw->GetCreationTime().toTime_t() < tdata->start)) {
+ tdata->start = thisw->GetCreationTime().toTime_t();
}
- if (thisw->creation_time > tdata->end) {
- tdata->end = thisw->GetCreationTime();
+ if (thisw->creation_time.toTime_t() > tdata->end) {
+ tdata->end = thisw->GetCreationTime().toTime_t();
if (tdata->start == 0) {
tdata->start = tdata->end;
}
if (global_opts.objective == trkdata) {
struct tm tm;
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *gmtime(&tt);
strftime(buf + 2, sizeof(buf) - 2, "%d%m%y %H%M%S ", &tm);
} else {
}
// if timestamps exist, distance to interpolated point
if (wpt1->GetCreationTime() != wpt2->GetCreationTime()) {
- frac = (double)(wpt3->GetCreationTime() - wpt1->GetCreationTime()) /
- (wpt2->GetCreationTime() - wpt1->GetCreationTime());
+ frac = (double)(wpt3->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t()) /
+ (wpt2->GetCreationTime().toTime_t() - wpt1->GetCreationTime().toTime_t());
linepart(wpt1->latitude, wpt1->longitude,
wpt2->latitude, wpt2->longitude,
frac, &reslat, &reslon);
case sm_description:
return strcmp(x1->description, x2->description);
case sm_time:
- return x1->GetCreationTime() - x2->GetCreationTime();
+ return x1->GetCreationTime().toTime_t() - x2->GetCreationTime().toTime_t();
default:
abort();
return 0; /* Internal caller error. */
DateTime(QDate date, QTime time) : QDateTime(date, time) {}
DateTime(QDateTime dt) : QDateTime(dt) {}
- // Handle time_tm tm = wpt->creation_time;
- operator time_t() const { return toTime_t(); }
-
const time_t& operator=(const time_t& t) {
setTime_t(t);
return t;
return toTime_t();
}
+ DateTime operator+(quint64 seconds) {
+ return DateTime::fromMSecsSinceEpoch(toMSecsSinceEpoch() + seconds*1000);
+ }
+
+ DateTime operator-(quint64 seconds) {
+ return DateTime::fromMSecsSinceEpoch(toMSecsSinceEpoch() - seconds*1000);
+ }
+
// Integer form: YYMMDD
int ymd() const {
QDate d(date());
const waypoint *wa = *(waypoint **)a;
const waypoint *wb = *(waypoint **)b;
- return wa->GetCreationTime() - wb->GetCreationTime();
+ return wa->GetCreationTime().toTime_t() - wb->GetCreationTime().toTime_t();
}
static void
*dist = 0; /* calc. diffs on 32- and 64-bit hosts */
}
- time = wpt->creation_time - trkpt_out->GetCreationTime();
+ time = wpt->creation_time.toTime_t() - trkpt_out->GetCreationTime().toTime_t();
if (time == 0) {
*speed = 0;
} else {
}
if ((all_points == 0) && (this_points == 0)) {
- start_time = wpt->GetCreationTime();
+ start_time = wpt->GetCreationTime().toTime_t();
}
this_points++;
this_distance = this_distance + dist;
if (trkpt_out != NULL) {
- this_time += (wpt->GetCreationTime() - trkpt_out->GetCreationTime());
+ this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t());
}
trkpt_out = (waypoint *)wpt;
track_points++;
all_track_points++;
- time_t ct = wpt->GetCreationTime();
+ time_t ct = wpt->GetCreationTime().toTime_t();
tm = *localtime(&ct);
strftime(tbuf, sizeof(tbuf), "%d.%m.%Y,%H:%M.%S", &tm);
static void
track_disp_custom_cb(const waypoint *wpt)
{
- if (wpt->GetCreationTime() && (wpt->altitude != unknown_alt)) {
- gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime() - start_time), wpt->altitude);
+ if (wpt->GetCreationTime().isValid() && (wpt->altitude != unknown_alt)) {
+ gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime().toTime_t() - start_time), wpt->altitude);
}
}
return;
}
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *gmtime(&tt);
tm.tm_year += 1900;
tm.tm_mon++;
time_t starttime;
time_t endtime;
- if (prevwpp->GetCreationTime() >= time_offset)
+ if (prevwpp->GetCreationTime().toTime_t() >= time_offset)
/* if this condition is not true, the waypoint is before the beginning of
* the video and will be ignored
*/
{
- starttime = gps_to_video_time(prevwpp->GetCreationTime());
+ starttime = gps_to_video_time(prevwpp->GetCreationTime().toTime_t());
if (!waypointp) {
endtime = starttime + 1;
} else {
- endtime = gps_to_video_time(waypointp->GetCreationTime());
+ endtime = gps_to_video_time(waypointp->GetCreationTime().toTime_t());
}
gbfprintf(fout, "%d\n", stnum);
stnum++;
} else if WAYPT_HAS(prevwpp, speed) {
gbfprintf(fout, "\n");
}
- subrip_write_time(prevwpp->GetCreationTime());
+ subrip_write_time(prevwpp->GetCreationTime().toTime_t());
gbfprintf(fout, " Lat=%0.5lf Lon=%0.5lf\n",
prevwpp->latitude + .000005,
prevwpp->longitude + .000005);
* way of solving this should be trivial to you :-)
*/
{
- time_offset = sync_time(waypointp->GetCreationTime(), opt_videotime);
+ time_offset = sync_time(waypointp->GetCreationTime().toTime_t(), opt_videotime);
}
if (prevwpp) {
{
int latint, lonint;
char tbuf[1024];
- time_t tm = wpt->GetCreationTime();
+ time_t tm = wpt->GetCreationTime().toTime_t();
int32_t utmz;
double utme, utmn;
char utmzc;
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata);
+ logtime = xml_parse_time(logpart->cdata).toTime_t();
logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
track_pts++;
wpt = (waypoint *)elem;
- if(wpt->creation_time == 0) timeless_pts++;
- if (!(opt_merge && opt_discard) && (need_time != 0) && (wpt->creation_time == 0)) {
+ if (!wpt->creation_time.isValid()) timeless_pts++;
+ if (!(opt_merge && opt_discard) && (need_time != 0) && (!wpt->creation_time.isValid())) {
fatal(MYNAME "-init: Found track point at %f,%f without time!\n",
wpt->latitude, wpt->longitude);
}
route_head *track = track_list[i].track;
QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
wpt = (waypoint *)elem;
- if(wpt->creation_time != 0) {
+ if(wpt->creation_time.isValid()) {
buff[j++] = waypt_dupe(wpt);
}
track_del_wpt(track, wpt);
}
if (interval > 0) {
- double tr_interval = difftime(buff[j]->GetCreationTime(),buff[i]->GetCreationTime());
+ double tr_interval = difftime(buff[j]->GetCreationTime().toTime_t(), buff[i]->GetCreationTime().toTime_t());
if (tr_interval <= interval) {
new_track_flag = 0;
}
RAD(wpt->longitude)));
}
if (opt_speed) {
- if (oldtime != wpt->GetCreationTime()) {
+ if (oldtime != wpt->GetCreationTime().toTime_t()) {
WAYPT_SET(wpt, speed, radtometers(gcdist(
RAD(oldlat), RAD(oldlon),
RAD(wpt->latitude),
RAD(wpt->longitude))) /
- labs(wpt->GetCreationTime()-oldtime));
+ labs(wpt->GetCreationTime().toTime_t()-oldtime));
} else {
WAYPT_UNSET(wpt, speed);
}
}
oldlat = wpt->latitude;
oldlon = wpt->longitude;
- oldtime = wpt->GetCreationTime();
+ oldtime = wpt->GetCreationTime().toTime_t();
}
}
}
QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
waypoint *wpt = (waypoint *)elem;
- if (wpt->creation_time > 0) {
- inside = ((wpt->GetCreationTime() >= start) && (wpt->GetCreationTime() <= stop));
+ if (wpt->creation_time.isValid()) {
+ inside = ((wpt->GetCreationTime().toTime_t() >= start) && (wpt->GetCreationTime().toTime_t() <= stop));
}
// If the time is mangled so horribly that it's
// negative, toss it.
- if (wpt->creation_time < 0) {
+ if (!wpt->creation_time.isValid()) {
inside = 0;
}
QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
waypoint *wpt = (waypoint *)elem;
- if (opt_faketime != 0 && (wpt->creation_time == 0 || faketime.force)) {
+ if (opt_faketime != 0 && (!wpt->creation_time.isValid() || faketime.force)) {
wpt->creation_time = QDateTime::fromTime_t(faketime.start);
faketime.start += faketime.step;
}
}
if (wpt->creation_time.isValid()) {
gb_setbit(&unicsv_outp_flags, fld_time);
- if (wpt->creation_time >= SECONDS_PER_DAY) {
+ if (wpt->creation_time.toTime_t() >= SECONDS_PER_DAY) {
gb_setbit(&unicsv_outp_flags, fld_date);
}
}
if (gc_data->is_available) {
gb_setbit(&unicsv_outp_flags, fld_gc_is_available);
}
- if (gc_data->exported) {
+ if (gc_data->exported.isValid()) {
gb_setbit(&unicsv_outp_flags, fld_gc_exported);
}
- if (gc_data->last_found) {
+ if (gc_data->last_found.isValid()) {
gb_setbit(&unicsv_outp_flags, fld_gc_last_found);
}
if (!gc_data->placer.isEmpty()) {
}
}
if FIELD_USED(fld_date) {
- if (wpt->creation_time >= SECONDS_PER_DAY) {
+ if (wpt->creation_time.toTime_t() >= SECONDS_PER_DAY) {
struct tm tm;
char buf[32];
- time_t time = wpt->GetCreationTime();
+ time_t time = wpt->GetCreationTime().toTime_t();
if (opt_utc) {
time += atoi(opt_utc) * SECONDS_PER_HOUR;
tm = *gmtime(&time);
} else {
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *localtime(&tt);
}
tm.tm_year += 1900;
}
}
if FIELD_USED(fld_time) {
- if (wpt->creation_time != 0) {
+ if (wpt->creation_time.isValid()) {
struct tm tm;
char buf[32], msec[12];
- time_t time = wpt->GetCreationTime();
+ time_t time = wpt->GetCreationTime().toTime_t();
if (opt_utc) {
time += atoi(opt_utc) * SECONDS_PER_HOUR;
tm = *gmtime(&time);
} else {
- const time_t tt = wpt->GetCreationTime();
+ const time_t tt = wpt->GetCreationTime().toTime_t();
tm = *localtime(&tt);
}
snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
}
if FIELD_USED(fld_gc_exported) {
if (gc_data) {
- unicsv_print_data_time(gc_data->exported);
+ unicsv_print_data_time(gc_data->exported.toTime_t());
} else {
gbfputs(unicsv_fieldsep, fout);
}
}
if FIELD_USED(fld_gc_last_found) {
if (gc_data) {
- unicsv_print_data_time(gc_data->last_found);
+ unicsv_print_data_time(gc_data->last_found.toTime_t());
} else {
gbfputs(unicsv_fieldsep, fout);
}
workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
- now = current_time();
+ now = current_time().toTime_t();
count = 0;
position = 0;
double
waypt_time(const waypoint *wpt)
{
- if (wpt->creation_time <= 0) {
+ if (!wpt->creation_time.isValid()) {
return (double) 0;
} else {
-
- return ((double)wpt->creation_time + ((double)wpt->creation_time.time().msec() / 1000));
+ return ((double)wpt->creation_time.toMSecsSinceEpoch()) / 1000.0;
}
}
void wfff_first(const char *args, const QXmlStreamAttributes* unused)
{
if (args) {
- ap_first = xml_parse_time(args);
+ ap_first = xml_parse_time(args).toTime_t();
}
}